<!doctype html>
<html class="no-js fixed-layout">
<head>
     <%
    include("/common/inc/meta.html"){}
    %>
    <title>管理员列表</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
</head>
<body>
<!--[if lte IE 9]>
<p class="browsehappy">你正在使用<strong>过时</strong>的浏览器，Amaze UI 暂不支持。 请 <a href="http://browsehappy.com/" target="_blank">升级浏览器</a>
    以获得更好的体验！</p>
<![endif]-->

<%
layout("/common/layout/layout.html",{'menu':'user'}){
%>

<div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">权限组</strong> / <small>列表</small></div>
</div>
 <div class="am-g">
      <div class="am-u-sm-12 am-u-md-6">
        <div class="am-btn-toolbar">
          <div class="am-btn-group am-btn-group-xs">
            <a type="button" class="am-btn am-btn-default" href="${ctxPath}/admin/group/save"><span class="am-icon-plus"></span> 新增</a>
            <button type="button" class="am-btn am-btn-default"><span class="am-icon-trash-o"></span> 删除</button>
          </div>
        </div>
      </div>
      <!-- <div class="am-u-sm-12 am-u-md-3">
        <div class="am-form-group">
          <select data-am-selected="{btnSize: 'sm'}">
            <option value="option1">用户名</option>
            <option value="option2">真实姓名</option>
            <option value="option3">手机号</option>
            <option value="option3">邮箱</option>
            <option value="option3">创建时间</option>
          </select>
        </div>
      </div> -->
      <div class="am-u-sm-12 am-u-md-3">
        <div class="am-input-group am-input-group-sm">
          <input type="text" class="am-form-field">
          <span class="am-input-group-btn">
            <button class="am-btn am-btn-default" type="button">搜索</button>
          </span>
        </div>
      </div>
    </div>

 <div class="am-g">
      <div class="am-u-sm-12">
          <table class="am-table am-table-bordered am-table-radius am-table-striped am-table-hover">
            <thead>
              <tr>
                <th class="table-check"><input type="checkbox" /></th><th class="table-title">权限组名称</th><th class="table-type">创建时间</th><th class="table-author am-hide-sm-only">描述</th><th class="table-set">操作</th>
              </tr>
          </thead>
          <tbody>
          	<%for(var item in page.content!){%>
            <tr>
              <td><input type="checkbox" /></td>
              <td><a href="#">${item.groupName}</a></td>
              <td>${dateFunc(item.createTime,"yyyy-MM-dd")}</td>
              <td class="am-hide-sm-only">${item.description}</td>
              <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">
                    <a class="am-btn am-btn-default am-btn-xs am-text-secondary" href="${ctxPath}/admin/group/update/${item.id!'null'}"><span class="am-icon-pencil-square-o"></span> 编辑</a>
                    <button class="am-btn am-btn-default am-btn-xs am-hide-sm-only"><span class="am-icon-copy"></span> 复制</button>
                    <button class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" name="deleteById" id="${item.id}"><span class="am-icon-trash-o"></span> 删除</button>
                  </div>
                </div>
              </td>
            </tr> 
            <%}%>           
          </tbody>
        </table>
             <%
    include("/common/inc/page.html"){}
    %>
          <hr />
          <p>注：.....</p>
      </div>

    </div>

<%}%>

<%
    include("/common/inc/js.html"){}
    %>

<script>		
	$(function(){
		var progress = $.AMUI.progress;	//加载进度条	
		
		$("button[name='deleteById']").click(function(){	
			var id=$(this).attr("id");
			progress.start();	
			var url="${ctxPath}/admin/group/delete/"+id;				
			$.ajax({
	            url:url,
	            method:"POST",
	            dataType:"JSON",
	            success:function(result){
	            	progress.done();
	            	console.log(result);
	            	if(result.errorCode!="0"){
	            		alert(result.errorMsg);
	            		return;
	            	}
	            	window.location.reload();
	            },
	            error:function(result){
	            	progress.done();
            		console.log(result);
            		if(result.status!=200){
            			//异常显示处理
            			if(result.responseText!=""){
            				var error=eval("("+result.responseText+")");
            				alert("错误代码: "+error.errorCode);
            			}else{
            				alert("网络异常");
            			}
            		}
	            }
	        })  
		})
	})
</script>
</body>
</html>